home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 August / 1987-08.d64 / relative files (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  73 lines

  1. 10 rem copyright 1987 compute! publications inc. - all rights reserved
  2. 20 print"[147]  copyright 1987 compute! pub., inc."
  3. 30 printtab(9)"all rights reserved"
  4. 40 open 15,8,15
  5. 50 open 1,8,2,"0:testrel"
  6. 60 input#15,e,e$,e1,e2
  7. 70 if e=0 goto230
  8. 80 close 1
  9. 90 if e<>62 then print e;e$;e1;e2:stop
  10. 100 print"creating file"
  11. 110 open 1,8,2,"0:testrel,l,"+chr$(33)
  12. 120 input#15,e,e$,e1,e2
  13. 130 if e<>0 then close 1:print e,e$,e1,e2:stop
  14. 140 print#15,"p"+chr$(98)+chr$(10)+chr$(0)+chr$(1)
  15. 150 input#15,e,e$,e1,e2
  16. 160 if e<>50 then close 1:print e;e$;e1;e2:stop
  17. 170 print#1,chr$(255);
  18. 180 input#15,e,e$,e1,e2
  19. 190 close 1
  20. 200 if e<>0 then print e;e$;e1;e2:stop
  21. 210 open 1,8,2,"0:testrel"
  22. 220 goto240
  23. 230 print"file already exists"
  24. 240 print"1. read all records"
  25. 250 print"2. write record"
  26. 260 print"3. quit"
  27. 270 input"which (1, 2 or 3)";x:print
  28. 280 on x goto300,440,710
  29. 290 goto240
  30. 300 r=0
  31. 310 r=r+1:f=0:x=0
  32. 320 h=int(r/256):l=r-h*256
  33. 330 print#15,"p"+chr$(98)+chr$(l)+chr$(h)+chr$(1)
  34. 340 input#15,e,e$,e1,e2
  35. 350 if e=50 goto240
  36. 360 if e<>0 then print e;e$;e1;e2:goto710
  37. 370 input#1,x$:sw=st
  38. 380 if x$=chr$(255) then print"record";r;"<empty>":goto310
  39. 390 if f=0 then print"record";r;":"
  40. 400 f=f+1:if sw=0 then x=1
  41. 410 print"     field";f;": ";x$
  42. 420 if sw=0 goto370
  43. 430 goto310
  44. 440 input"write to record number";r
  45. 450 if r<1 or r<>int(r) goto440
  46. 460 if r>40 then print "too big!":goto570
  47. 470 h=int(r/256):l=r-h*256
  48. 480 print#15,"p"+chr$(98)+chr$(l)+chr$(h)+chr$(1)
  49. 490 input#15,e,e$,e1,e2
  50. 500 if e=50 then print"a new one!"
  51. 510 input"how many fields (1-3)";n
  52. 520 if n<1 or n>3 goto510
  53. 530 a$=""
  54. 540 print"enter data:"
  55. 550 for j=1 to n
  56. 560 if n<>1 then print"field";j;
  57. 570 input b$
  58. 580 a$=a$+b$+chr$(13)
  59. 590 next j
  60. 600 a$=left$(a$,len(a$)-1)
  61. 610 print#1,a$;
  62. 620 input#15,e,e$,e1,e2
  63. 630 if e<>0 then print e;e$;e1;e2
  64. 640 close 1
  65. 650 input#15,e,e$,e1,e2
  66. 660 if e<>0 then print e;e$;e1;e2
  67. 670 open 1,8,2,"0:testrel"
  68. 680 input#15,e,e$,e1,e2
  69. 690 if e<>0 then print e;e$;e1;e2
  70. 700 goto240
  71. 710 close 1
  72. 720 close 15
  73.